<template>
    <van-cell-group inset>
        <van-field v-model="value" label="用户名" placeholder="请输入用户名" />
        <van-field v-model="password" type="password" label="密码" />
        <van-button type="default" @click="register()">注册</van-button>
    </van-cell-group>
</template>

<script setup lang="ts">
import { showToast } from 'vant';
import axios from '../utils/http';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();
const value = ref('');
const password = ref('');
const data = ref('');
const register = async () => {
    const res: any = await axios.post('users/register', {
        username: value.value,
        userpwd: password.value
    })
    if (res.status === 201) {
        showToast('注册成功');
        data.value = res;
        console.log(data.value);
        router.push('/login');
    }

}
</script>

<style></style>